#include<bits/stdc++.h>
using namespace std;

class Solution {
public:
    vector<int> decode(vector<int>& encoded, int first) {
        vector<int> res(encoded.size() + 1);
        res[0] = first;

        int pre = first;
        for (int i = 1; i < encoded.size() + 1; i++)
        {
            res[i] = pre ^ encoded[i-1];
            pre = res[i];
        }

        return res;
    }
};